package hotel.base.oversea.entity;

import com.fasterxml.jackson.annotation.JsonFormat;
import hotel.base.oversea.utils.StringUtil;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import org.springframework.context.annotation.Primary;
import org.springframework.format.annotation.DateTimeFormat;

import javax.persistence.Column;
import java.io.Serializable;
import java.util.Date;

/**
 * 基础entity
 * 公有字段
 */
@Data
@Primary
public class BaseEntity implements Serializable {


    private static final long serialVersionUID = 1L;

    /**
     * 主键
     */
    @ApiModelProperty(name = "id" , value = "主键id")
    private String id=StringUtil.getUUID();

//    /**
//     * 是否删除 0否；1是
//     */
//    @Column(name = "is_del")
//    private Boolean isDel = false;


    /**
     *系统状态   0:正常  1:异常
     */
    @Column(name = "state")
    private Integer state;

    /**
     * 创建时间
     */
    @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
    @Column(name = "create_time")
    @ApiModelProperty(name = "create_time" , value = "创建时间")
    private Date createTime;

    /**
     * 修改时间
     */
    @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
    @Column(name = "modify_time")
    @ApiModelProperty(name = "modify_time" , value = "修改时间")
    private Date modifyTime=new Date();

    /**
     * 备注
     */
    @ApiModelProperty(name = "remark" , value = "备注")
    private String remark;

//    /**
//     * @Version注解说明：<br>
//     * 更新时，实体对象的version属性必须有值，才会生成SQL update ... WHERE ... and version=?
//     *
//     * 使用 FieldFill.INSERT 不要使用 INSERT_UPDATE 或 update
//     */
//    @Version
//    @TableField(value="version", fill = FieldFill.INSERT, update="%s+1")
//    private Long version;

}
